﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Lamex.Library;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace Lamex.mNC.UI
{
    public partial class frmNC_StlViewer : frmBaseChild
    {
        [DllImport("User32.dll ", EntryPoint = "SetParent")]
        private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        [DllImport("user32.dll ", EntryPoint = "ShowWindow")]
        public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);

        public frmNC_StlViewer()
        {
            InitializeComponent();
        }

        private void frmNC_StlViewer_Load(object sender, EventArgs e)
        {
            string fexePath = @"\\Tx-fs10\tx-fs1\LAMEX\NC\Tools\STL"; // 外部exe位置

            Process p = new Process();
            p.StartInfo.FileName = fexePath + @"\STLView.exe";
            //p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            p.Start();

            while (p.MainWindowHandle.ToInt32() == 0)
            {
                System.Threading.Thread.Sleep(100);
            }
            SetParent(p.MainWindowHandle, this.Handle);
            ShowWindow(p.MainWindowHandle, (int)ProcessWindowStyle.Maximized);
        }
    }
}